

import MainManager from "../manager/main_manager";
import PoolManager from "../manager/pool_manager";
import StorageManager from "../manager/storage_manager";
import { Emitter } from "../utils/emmiter";
import { MessageType } from "../utils/message";
import Enemy from "./Enemy";

const { ccclass, property } = cc._decorator;

@ccclass
export default class DamageArea extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property
    text: string = 'hello';
    atk: number = 10;
    oriPos: cc.Vec3

    onLoad() {
        this.oriPos = this.node.position
    }



    onCollisionEnter(other, self) {
        let enemy = other.getComponent(Enemy)
        if (enemy) {
            enemy.isMoving = false;
            enemy.doAttack()

            // MainManager.instance.removeEnemyById(other.getComponent(Enemy).globalId)
            // other.node.destroy()
        }

    }

    doFlash() {
        let duration = 0.5;
        let target = this.node
        cc.tween(target).to(duration / 2, { opacity: 128 }).to(duration / 2, { opacity: 255 }).start()  // 击退过程中节点的透明度渐变
        // cc.tween(target)
        //     .parallel(
        //         // cc.tween(target).by(duration, {
        //         //     position: cc.v3(0, -15,0)
        //         // }),
        //         cc.tween(target).to(duration / 2, { opacity: 128 }).to(duration / 2, { opacity: 255 })  // 击退过程中节点的透明度渐变
        //     )
        //     // .call(()=>{
        //     //     this.node.position = this.oriPos
        //     // })
        //     .start();
    }


}
